package com.niubility.other;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Config {
    //定义配置文件的路径
    private static String configFilePath="qiniu.properties";
    private static Properties p;
    public static void setConfigFilePath(String configFilePath) {
        Config.configFilePath = configFilePath;
    }

    //加载配置文件
    private static void init() {
        //属性文件类
        p=new Properties();
        InputStream inStream=Config.class.getClassLoader().getResourceAsStream(configFilePath);
        if(inStream!=null) {
            try {
                p.load(inStream);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static String getValue(String key) {
        if(p==null)
            init();
        return p.getProperty(key);

    }
}
